/*
 * CardFactory.java $version 2011. 5. 19.
 *
 * Copyright 2007 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package com.luffy.mafia.carddeck;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.luffy.mafia.card.CharacterCard;
import com.luffy.mafia.character.MafiaCharacterType;

/**
 * Class 내용 기술
 * <pre>
 * 파일명          : CardFactory.java
 * 작성일          : 2011. 5. 19.
 * 버젼            : 1.0
 * 수정내용
 * -----------------------------------------------------------------
 * 수정일           버젼      수정자       수정내용
 * -----------------------------------------------------------------
 * </pre>
 *
 * @author LuffeEve
 */
public class CardFactory {
	private static Logger log = Logger.getLogger(CardFactory.class);
	
	private Map<MafiaCharacterType, CharacterCard> cardPool = new HashMap<MafiaCharacterType, CharacterCard>();

	/**
	 * <pre>
	 *
	 * @param citizen
	 * </pre>
	 */
	public CharacterCard getCard(MafiaCharacterType cardType) {
		CharacterCard card = cardPool.get(cardType);
		CharacterCard newCard = null;
		try {
			newCard = card.getClass().newInstance();
			newCard.setCard(card);
		} catch (InstantiationException e) {
			log.error(e.getMessage(), e);
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			log.error(e.getMessage(), e);
			throw new RuntimeException(e);
		}
		return newCard;
	}

	public void setCardPool(Map<MafiaCharacterType, CharacterCard> cardPool) {
		this.cardPool = cardPool;
	}

	public Map<MafiaCharacterType, CharacterCard> getCardPool() {
		return cardPool;
	}
}
